<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
	<style type="text/css">
		*{
			margin: 0px;
			padding: 0px;
			font-size: 12px;
		}
	</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		 <div class="iboxtitle">
             <span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理>业务申请>修改订单业务员</span>
         </div>
         <div class="ibox-content ibox-zxsearchqu ">
               <div class="row">
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                  	 <div class="row">
                  	 	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                   	   <label class="sr-only">客户名：</label>
	                       <input type="text" placeholder="客户名" id="customerName" name="customerName" class="form-control">
	                     </div>
	                     <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">    
	                       <label class="sr-only">业务员：</label>
	                       <input type="text" placeholder="业务员" id="salesmanName" name="salesmanName" class="form-control">
	                      </div> 
	                  </div>     
                   </div>
                   <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
                   		<div class="row">
                   			<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
                   				<input id="submitTimeStart" name="submitTimeStart" placeholder="开始时间" class="laydate-icon form-control">
                   			</div>
                   			<label class="hxleft">至</label>
	                        <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">  
	                        	<input id="submitTimeEnd" name="submitTimeEnd" placeholder="结束时间" class="laydate-icon form-control">
	                        </div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
	                    <button class="btn dpbtn_blue_null" type="button" onclick="query(0,0);">当日</button>
						<button class="btn dpbtn_blue_null" type="button" onclick="query(-1,-1);">昨日</button>
						<button class="btn dpbtn_blue_null" type="button" onclick="query(-6,0);">近7日</button>
                   		<button class="zhixcx" type="button" onclick="query();">执行查询</button>
                    </div>
          	</div>
          </div>
          
          <div class="ibox-content">
          	<span class="warning-label"><span class="red-dp-circle"></span>尚未提交初审的订单可变更业务员</span>	
          	<div class="jqGrid_wrapper">
	             <table id="table_list_1"></table>
	             <div id="pager_list_1"></div>
         	</div>
          </div>
          
          <div class="ibox-content" id="salemanHide" style="display: none;">
          		<!-- 隐藏域 -->
          		<input  class="form-control" type="hidden" id="busiId" name="busiId" readonly="readonly"/>
          		<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table zx-addtable">
          		    <tr>	
						<td align="right">
							<label class="control-label np">原部门：</label>
						</td>
						<td>
							<input  class="form-control" type="text" id="v_orgName" name="v_orgName" readonly="readonly"/>
						</td>
				    </tr>
				    <tr>	
						<td align="right">
							<label class="control-label np">原业务员：</label>
						</td>
						<td>
						    <input  class="form-control" type="hidden" id="v_salemanId" name="v_salemanId" readonly="readonly"/>
							<input  class="form-control" type="text" id="v_salemanName" name="v_salemanName" readonly="readonly"/>
						</td>
				    </tr>
          			<tr>	
						<td align="right">
							<label class="control-label np">业务员：</label>
						</td>
						<td>
							<input  class="form-control" type="hidden" id="salemanId" name="salemanId" />
							<input  class="form-control smalliconcur smallicon" required="required" placeholder="业务员(必填)"  type="text" id="salemanName" name="salemanName" onclick="salemancho('',false);"  />
						</td>
				    </tr>
				    <tr>	
						<td align="right" valign="top">
							<label class="control-label np">备注：</label>
						</td>
						<td>
							<textarea id="remarks" name="remarks" rows="3" cols="" class="form-control"></textarea>
						</td>
				    </tr>
          	   </table>	
          	   <table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">
				<tr>
					<td width="100%" align="center">
						 <div class="ibox-content">
				              	<button class="btn dpbtn_red" type="button" onclick="updateYw();">修改</button>
				          </div>
					</td>
				</tr>
			</table>
          </div>
	</div>
	
	<!-- 业务员-->
	<%@include file="/jsp/ywychoice_js_include.jsp"%>
	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
    
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    
	    var winWidth = $(window).width();
		var winHeight = $(window).height();
		
	    jQuery(function($) {  
	    	
	    	//外部js调用
		    laydate({
		        elem: '#submitTimeStart', 
		        event: 'focus' 
		    });
	    	
		    laydate({
		        elem: '#submitTimeEnd', 
		        event: 'focus' 
		    });
	    	
	    	getData();
	    });
	    
	    var getData = function()
	    {
	       var winWidth = $('div.ibox-content').width();
	   	   var winHeight = document.body.offsetHeight - 330;
	       var win = winWidth / 7 - 10;
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
  	 	   
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/DaiZhongYwController/getYwYuanList',
	        datatype : "json",
	        colNames : [ '主键', '业务编号','业务提交时间', '订单类型', '部门','业务员', '客户姓名', '身份证号码', '银行','unitCode','salersmanId'],
	        colModel : [ 
	                     {name: 'replaceId', index: '', hidden:true},
	                     {name: 'busiCode', index: '', hidden:true},
	                     {name: 'submitTime',index: '',width: win,align: "center",sortable: false},
	                  	 {name: 'channelType',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'orgName',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'creatorName',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'customerName',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'customerNo',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'bankLoan',index: '',width: win,align: "center",sortable: false},
	            		 {name: 'unitCode',index: '',width: win,hidden:true,sortable: false},
	            		 {name: 'salersmanId',index: '',width: win,hidden:true,sortable: false}
	                   ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              shrinkToFit:false,
              autoScroll: false,
              rowNum: 15,
              rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
              altclass:'someClass',
              ondblClickRow:function(rowId)
              {
            	  var row = $("#table_list_1").jqGrid("getRowData",rowId);
            	  $('#v_orgName').val(row.orgName);
            	  $('#v_salemanName').val(row.creatorName);
            	  $('#v_salemanId').val(row.salersmanId);
            	  $('#busiId').val(row.replaceId);
            	  
            	  //页面层
            	 varsalemanHide = layer.open({
            	    type: 1,
            	    area: ['400px', '460px'], //宽高
            	    content: $('#salemanHide')
            	  });
              },
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
             	  if (datas.flag == "100100") {
                       layer.msg("查询成功!", {icon: 6, time: 1000});
                       return;
                   }
             	 if(datas.flag == '100802') {
    				  top.location.href = thisLoginUrl;
    				  return;
    			  }

             	  layer.msg(datas.message, {icon: 2});
               }
	      });
	    }	    
	    
	    var varsalemanHide;
	    
	    window.onresize = function()
	    {
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	    
	    var query = function(start, end){
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.customerName = document.getElementById('customerName').value || '';
	    	data.salesmanName = document.getElementById('salesmanName').value || '';
	    	if(start != null && typeof start != 'undefined') {
	    		document.getElementById('submitTimeStart').value = laydate.now(start);
	    		document.getElementById('submitTimeEnd').value = laydate.now(end);
	    	}
	    	data.submitTimeStart = document.getElementById('submitTimeStart').value.trim();
	    	data.submitTimeEnd = document.getElementById('submitTimeEnd').value.trim();
	    	
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
	    
	    //业务员修改
	    var updateYw = function()
	    {
	    	var salemanId = $('#salemanId').val();
	    	var salemanName = $('#salemanName').val();
	    	var v_salemanId = $('#v_salemanId').val(); 
	    	var busiId = $('#busiId').val();
	    	var remarks = $('#remarks').val();
	    	
	    	if(salemanId == "" || salemanName == "")
	    	{
	    		layer.msg("业务员不能为空", {icon: 5});
	    		return;
	    	}
	    	
	    	if(v_salemanId == salemanId)
	    	{
	    		layer.msg("已经是此业务员", {icon: 5});
	    		return;
	    	}
	    	
	    	if(remarks == "")
	    	{
	    		layer.msg("备注信息不能为空", {icon: 5});
	    		return;
	    	}
	    	
	    	//询问框
			layer.confirm('确定执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			  btn: ['确认','取消'] //按钮
			}, function(){
				layer.closeAll();
		    	$.dpAjax({
			   		url:'${basePath}/DaiZhongYwController/updateYw',
					data:{
						"busiId":busiId,
						"salesmanIdOld":v_salemanId,
						"salesmanIdNow":salemanId,
						"remarks":remarks
					},
					success: function(datas)
					{
		   			  if(datas.flag == "100100")
					  {
		   				  layer.msg("执行成功！", {icon: 6});
		   				  layer.close(varsalemanHide);
		   				  refresh();
						  return;
					  }
					  layer.msg(datas.message, {icon: 2});
					}
				});
			}, function(){
				layer.msg('已取消本次操作！', {icon: 6});
			});
	    }
    </script>
</body>
</html>
